<!--上传微信群二维码-->
<template>
    <f7-page no-toolbar>
        <f7-navbar title="上传聚会群二维码" back-link="Back"></f7-navbar>
        <f7-block>注意：微信群二维码有效期7天，过期请主动更新哦</f7-block>
        <uploader
                url="http://cn.ynhdkc.com/admin/uploadapiv2/uploadpics"
        ></uploader>
        <f7-list style="text-align: center;width: 90%;margin-top: -24px;margin-left: 5%;">
            <f7-button fill round text="上传" @click="upload"></f7-button>
        </f7-list>
    </f7-page>
</template>

<script>
    import {mapState} from 'vuex'

    export default {
        data() {
            return {
                imgs: []
            }
        },
        computed: {
            ...mapState({
                imgStatus: state => state.imgstore.img_status,
                imgPaths: state => state.imgstore.img_paths
            })
        },
        methods: {
            upload() {
                this.$store.commit('set_img_status', 'uploading')
            },
            submit() {
                let values = []
                for (let key of this.imgPaths) {
                    values.push(key)
                }
                this.imgs = values
                console.log(this.imgs)
            }
        },
        watch: {
            imgStatus() {
                if (this.imgStatus === 'finished') {
                    this.submit()
                }
            }
        },
        destoryed() {
            this.imgs = []
        }
    }
</script>

<style scoped lang="less">
    .btn {
        width: 100%;
        height: 3em;
        background-color: green;
        color: #fff;
        display: flex;
        justify-content: center;
        align-items: center;
    }
</style>
